package com.pb.b2b.model;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Type;

import com.pb.b2b.model.enums.Status;

@Entity
@Table(name = "LANGUAGE")
public class Language {

	private Long id;
	private String name;
	private String code;
	private String active;
	private Status status;
	private boolean deleted;
	private Date dateAdded;
	private Date dateModified;
	private Set<CategoryLanguage> categoryLanguages = new HashSet<CategoryLanguage>(0);

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = "ID", nullable = false, unique = true)
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	@Column(name = "NAME", nullable = false, unique = true)
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "CODE", nullable = false, unique = true)
	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	@Column(name = "ACTIVE", nullable = true)
	public String getActive() {
		return active;
	}

	public void setActive(String active) {
		this.active = active;
	}

	@Column(name = "STATUS", nullable = true)
	public Status getStatus() {
		return status;
	}

	public void setStatus(Status status) {
		this.status = status;
	}

	@Column(name = "DELETED", nullable = false)
	@Type(type = "org.hibernate.type.BooleanType")
	public boolean isDeleted() {
		return deleted;
	}

	public void setDeleted(boolean deleted) {
		this.deleted = deleted;
	}

	@Column(name = "DATE_ADDED", nullable = false)
	public final Date getDateAdded() {
		return dateAdded;
	}

	public final void setDateAdded(Date dateAdded) {
		this.dateAdded = dateAdded;
	}

	@Column(name = "DATE_MODIFIED", nullable = false)
	public final Date getDateModified() {
		return dateModified;
	}

	public final void setDateModified(Date dateModified) {
		this.dateModified = dateModified;
	}

	@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "language")
	public Set<CategoryLanguage> getCategoryLanguages() {
		return categoryLanguages;
	}

	public void setCategoryLanguages(Set<CategoryLanguage> categoryLanguages) {
		this.categoryLanguages = categoryLanguages;
	}

}
